package com.mz.ozy.activity.me;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.jude.rollviewpager.RollPagerView;
import com.mz.ozy.R;
import com.mz.ozy.activity.home.PopularActivity;
import com.mz.ozy.activity.home.PopularDetailActivity;
import com.mz.ozy.adapter.PopularHAdapter;
import com.mz.ozy.adapter.ReciproBannerAdapter;
import com.mz.ozy.adapter.ReciprocityAdapter;
import com.mz.ozy.base.BaseActivity;
import com.mz.ozy.bean.MyApplyMeetBean;
import com.mz.ozy.bean.MyApplyMeetResBean;
import com.mz.ozy.bean.PopularBean;
import com.mz.ozy.bean.ReciprocityBean;
import com.mz.ozy.mvp.presenter.ApplyMeetPresenter;
import com.mz.ozy.mvp.view.ApplyMeetContract;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ApplyMeetActivity extends BaseActivity<ApplyMeetContract.View, ApplyMeetPresenter> implements ApplyMeetContract.View {

    @BindView(R.id.rollPagerView)
    RollPagerView rollPagerView;
    @BindView(R.id.iv_bannerPager)
    ImageView ivBannerPager;

    @BindView(R.id.btn_apply_meet)
    Button applyMeetBtn;

    @BindView(R.id.tv_vip_num)
    TextView tvVipNumTextView;

    @BindView(R.id.tv_vip)
    TextView tvVipextView;

    @BindView(R.id.tv_gold_name)
    TextView tvGoldNameTextView;

    @BindView(R.id.tv_health_assist)
    TextView tvHealthAssistTextView;

    private ReciproBannerAdapter mBannerAdapter;
    private List<ReciprocityBean.ImgBannerBean> mBannerListBeans = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply_meet);
        ButterKnife.bind(this);
        initTitle2();
        intiView();
        tvCenterTitle.setText("有机事业会议");

        applyMeetBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPresenter.apply(ApplyMeetActivity.this);
            }
        });
        mPresenter.applyRes(this);
    }

    void intiView() {
        mBannerAdapter = new ReciproBannerAdapter(this, mBannerListBeans);
        rollPagerView.setAdapter(mBannerAdapter);
    }

    @Override
    public void applyResSuccess(MyApplyMeetBean bean) {
        tvVipNumTextView.setText(bean.totalMember+"");
        tvVipextView.setText(bean.vipNum + "");
        tvGoldNameTextView.setText(bean.drillNum + "");
        tvHealthAssistTextView.setText(bean.healthNum + "");

        mBannerListBeans.clear();
        final List<ReciprocityBean.ImgBannerBean> bannerList = bean.imgList;
        if (bannerList != null && bannerList.size() > 0) {
            for (ReciprocityBean.ImgBannerBean bannerListBean : bannerList) {
                mBannerListBeans.add(bannerListBean);
            }
        } else {
            rollPagerView.setVisibility(View.GONE);
            ivBannerPager.setVisibility(View.VISIBLE);
        }
        mBannerAdapter.notifyDataSetChanged();
    }

    @Override
    public void applySuccess(MyApplyMeetResBean bean) {
        startActivity(new Intent(ApplyMeetActivity.this, ApplyMeetOkActivity.class));
    }
}